import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      //meta: { title: 'Dashboard', icon: 'dashboard' }
      meta: { title: '主页', icon: 'el-icon-s-home' }
    }]
  },
  {
    path: '/order',
    component: Layout,
    redirect: '/order/index',
    name:'Order',
    meta: { title: '订单', icon: 'el-icon-tickets' },
    children: [
      {
        path: 'order',
        name: 'order',
        component: () => import('@/views/order/index'),
        meta: { title: '订单处理' }
      },
      {
        path: 'ordersSel',
        name: 'ordersSel',
        component: () => import('@/views/orderSel/index'),
        meta: { title: '订单查询'}
      }
    ]
  },


  {
    path: '/goods',
    component: Layout,
    children: [
      {
        path: 'goods',
        name: 'Goods',
        component: () => import('@/views/goods/index'),
        meta: { title: '商品', icon: 'el-icon-food' }
      }
    ]
  },
  {
    path:'/weather',
    component:Layout,
    children:[
      {
      path:'weather',
      name:'Weather',
      component: () => import('@/views/weather/index'),
      meta:{title:'天气',icon:'el-icon-weather'}
    }
  ]
  },
  {
    path: '/users',
    component: Layout,
    redirect: '/users/index',
    name:'User',
    meta: { title: '顾客', icon: 'el-icon-s-custom' },
    children: [
      {
        path: 'users',
        name: 'users',
        component: () => import('@/views/users/index'),
        meta: { title: '顾客列表' }
      },
      {
        path: 'usersAdd',
        name: 'usersAdd',
        component: () => import('@/views/usersAdd/index'),
        meta: { title: '顾客地址' }
      }
    ]
  },

{
    path: '/business',
    component: Layout,
    redirect: '/business/index',
    name: 'Business',
    meta: { title: '商家', icon: 'el-icon-s-shop' },
    children: [
      {
        path: 'business',
        name: 'business',
        component: () => import('@/views/business/index'),
        meta: { title: '商家列表' }
      },
      {
        path: 'businessClassIfication',
        name: 'businessClassIfication',
        component: () => import('@/views/businessClassIfication/index'),
        meta: { title: '商家分类' }
      }
    ]
  },


  { path: '*', redirect: '/404', hidden: true }
]

const createRouter = () => new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
